﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace Part3_IndividuleAssignment2.Models
{
    public class Account
    {
        const string EMAIL_REGEX =
                  @"^(([^<>()[\]\\.,;:\s@\""]+"
                + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@"
                + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
                + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+"
                + @"[a-zA-Z]{2,}))$";

        public int ID { get; set; }

        [Required(ErrorMessage="First name is required")]
        [MaxLength(20,ErrorMessage="First name must be between 2 to 20 characters.")]
        [MinLength(2, ErrorMessage = "First name must be between 2 to 20 characters.")]
        public string FirstName { get; set; }

        [Required(ErrorMessage = "Last name is required")]
        [MaxLength(20, ErrorMessage = "Last name must be between 2 to 20 characters.")]
        [MinLength(2, ErrorMessage = "Last name must be between 2 to 20 characters.")]
        public string LastName { get; set; }

        [Required(ErrorMessage = "Email address is required")]
        [RegularExpression(EMAIL_REGEX, ErrorMessage = "Not a valid email address")]
        public string Email { get; set; }

        [Required]
        public virtual City City { get; set; }

        public virtual ICollection<NewsItem> NewsItems { get; set; }
    }
}